package com.guomao;

import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.ArrayList;


@WebServlet("/msa")
public class MyServletA extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        ArrayList<String> list = new ArrayList<>();
//
//        list.add("歼-10");
//        list.add("苏30");
//        list.add("阵风");
//        req.setAttribute("list", list);
//
//        req.getRequestDispatcher("/index.jsp").forward(req, resp);


        ServletContext context = req.getServletContext();

        context.setAttribute("msg", "abc");

        context.setAttribute("msg", "123");

        context.removeAttribute("msg");

        /*for (int i = 0; i < list.size(); i++) {
            String s = list.get(i);
            System.out.println(s);
        }*/
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
